<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>配置方案信息</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../../../elementUI/index.css">
    <link rel="stylesheet" href="../../../../css/index.css">
</head>

<body>
    <div id="app" class="minWidth">
        <el-form :model="form" ref="contract" :rules="rules" inline-message="true" style="width: 100%">
            <div class="table_titel">
                <div class="titel">生效时间</div>
            </div>
            <el-descriptions :column="3" border size="small">
                <el-descriptions-item label="是否长期">
                    <el-form-item prop="Type_Date">
                        <el-select style="width: 100%;" @change="handleDate" placeholder="请选择商品" filterable
                            v-model.trim="form.Type_Date">
                            <el-option label="短期" value="0"></el-option>
                            <el-option label="长期" value="1"></el-option>
                        </el-select>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item label="开始时间">
                    <el-form-item prop="Start_Date">
                        <el-date-picker style="width: 100%;" v-model.trim="form.Start_Date" type="datetime"
                            placeholder="请选择开始时间" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item label="结算时间">
                    <el-form-item prop="End_Date">
                        <el-date-picker style="width: 100%;" :disabled="form.Type_Date=='1'"
                            v-model.trim="form.End_Date" type="datetime" placeholder="请选择结算时间"
                            value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                    </el-form-item>
                </el-descriptions-item>
            </el-descriptions>
            <div class="table_titel">
                <div class="titel">适用商品</div>
                <div class="operation">
                    <el-button type="primary" size="small" @click="add_member_share_config_article">新增</el-button>
                    <el-button type="danger" size="small" @click="remove_member_share_config_article">删除</el-button>
                </div>
            </div>
            <el-descriptions
                :style="form.Children.member_share_config_article.length-1==index?'margin-bottom: 100px;':'margin-bottom: 10px;'"
                :column="2" border size="small" v-for="(item,index) in form.Children.member_share_config_article"
                :key="index">
                <el-descriptions-item :label="index+1+'.适用商品'">
                    <el-form-item :prop="'Children.member_share_config_article.'+index+'.Article_SerialNumber'"
                        :rules="[{ required: true, message: '请输入开始时间', trigger: 'blur' }]">
                        <el-select style="width: 100%;" placeholder="请选择商品" filterable
                            v-model.trim="item.Article_SerialNumber">
                            <el-option v-for="(item,index) in article" :key="index" :label="item.Article_Name"
                                :value="item.Article_SerialNumber"></el-option>
                        </el-select>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item label="方案类型">
                    <el-form-item>
                        <el-select style="width: 100%;" placeholder="请选择方案类型" filterable
                            v-model.trim="item.Divide_Type">
                            <el-option v-for="(item,index) in arr" :key="index" :label="item.label"
                                :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item :label="item.Divide_Type=='0'?'分销比例':'分销金额'">
                    <el-form-item>
                        <el-input style="width: 100%;" v-model.trim="item.Divide_Amount"
                            placeholder="请输入方案金额"></el-input>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item label="分润天数">
                    <el-form-item>
                        <el-input style="width: 100%;" v-model.trim="item.Divided_Days"
                            placeholder="请输入分润天数"></el-input>
                    </el-form-item>
                </el-descriptions-item>
            </el-descriptions>
            <el-form-item class="form-operation">
                <el-button @click="window.history.back()">返回</el-button>
                <el-button @click="()=>{this.dialogVisible = true}">导入</el-button>
                <el-button type="primary" :loading="loading" @click="submitForm('contract')">提交</el-button>
            </el-form-item>
        </el-form>
        <el-dialog title="导入表格" width="70%" :visible.sync="dialogVisible">
            <el-select @change="handleDate" placeholder="请选择商品" filterable
                v-model.trim="form.Type_Date">
                <el-option label="短期" value="0"></el-option>
                <el-option label="长期" value="1"></el-option>
            </el-select>
            <el-date-picker v-model.trim="form.Start_Date" type="datetime" placeholder="请选择开始时间"
                value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
            <el-date-picker v-model.trim="form.End_Date" type="datetime" placeholder="请选择结束时间"
                value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
            <div style="height: 50px;">
                <el-upload id="Excel" class="upload-demo" action="" :before-remove="beforeRemove" :file-list="fileList"
                    :before-upload="uploadDetails">
                    <el-button size="small" type="primary" v-show="fileList.length<1">导入</el-button>
                    <span slot="tip" class="el-upload__tip" v-show="fileList.length<1">请上传xlsx表格</span>
                </el-upload>
            </div>
            <div style="margin-bottom: 20px;">
                <el-table :data="tableData" stripe border height="calc(60vh - 140px)" style="width: 100%">
                    <el-table-column label="序号" width="50" type="index"></el-table-column>
                    <el-table-column prop="Article_SerialNumber" label="商品id"></el-table-column>
                    <el-table-column prop="Article_Name" label="商品名称"></el-table-column>
                    <el-table-column prop="Divide_Type" label="方案类型">
                        <template v-slot="{row}">
                            {{row.Divide_Type=='0'?'指定分销金额':'根据订单成交额的百分比'}}
                        </template>
                    </el-table-column>
                    <el-table-column prop="Divide_Amount" label="分销金额"></el-table-column>
                    <el-table-column prop="Divided_Days" label="分润天数"></el-table-column>
                </el-table>
            </div>
            <div style="display: flex; justify-content: center; width: 100%;">
                <el-button  @click="download" type="success">下载模板</el-button>
                <el-button type="primary" :loading="loading" @click="submit">提交</el-button>
            </div>
        </el-dialog>
    </div>
    <script type="text/javascript" src="../../../../js/jquery-3.6.0.min.js"></script>
    <script type="text/javascript" src="../../../../js/jquery.cookie.js"></script>
    <script type="text/javascript" src="../../../../js/vue.min.js"></script>
    <script type="text/javascript" src="../../../../elementUI/index.js"></script>
    <script type="text/javascript" src="../../../../js/utils.js"></script>
    <script type="text/javascript" src="../../../../js/ID_Validity.js"></script>
    <script type="text/javascript" src="../../../../js/FileSaver.min.js"></script>
    <script type="text/javascript" src="../../../../js/FileSaver.js"></script>
    <script type="text/javascript" src="../../../../js/xlsx.full.min.js"></script>
    <script type="text/javascript" src="./js/Add.js"></script>
</body>

</html>